<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>计算属性，方法与侦听器</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
            {{fullName}}
        {{age}}
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                firstName: "Dell",
                lastName: "Lee",
                fullName: "Dell Lee",
                age: 25
            },
            //计算属性
            // computed: {
            //     fullName: function() {
            //         console.log('有缓存了');
            //         return this.firstName + " " + this.lastName;
            //     }
            // }

            //方法
            // methods: {
            //     fullName: function (){
            //         console.log('输出了');
            //         return this.firstName + " " + this.lastName;
            //     }
            // }

            watch: {
                firstName: function() {
                    console.log('结算了');
                    this.fullName = this.firstName + " " + this.lastName;
                },
                lastName: function() {
                    console.log('zheng');
                    this.fullName = this.firstName + " " + this.lastName;
                }

            }
        });
    </script>
</body>
</html>